package com.turbo.boot.crawler.spider.worker.impl.quota;

import com.turbo.boot.crawler.spider.worker.BaseTurboCrawler;
import com.xuxueli.crawler.annotation.PageFieldSelect;
import com.xuxueli.crawler.annotation.PageSelect;
import lombok.Getter;
import lombok.Setter;

/**
 * 描述
 *
 * @author wuyn
 * @since 2024/4/17
 */
//@Service("demoCrawler")
public class DemoCrawler extends BaseTurboCrawler<DemoCrawler.DemoPageVo> {


//    @PostConstruct
//    public void init() {
//        crawlerConfig.setUrls("https://gitee.com/xuxueli0323/projects?page=1");
//        crawlerConfig.setWhiteUrlRegexs("https://gitee\\.com/xuxueli0323/projects\\?page=\\d+");
//    }


//    @Override
//    protected PageParser<DemoCrawler.DemoPageVo> getPageParser() {
//        return new PageParser<DemoPageVo>() {
//            @Override
//            public void parse(Document html, Element pageVoElement, DemoPageVo pageVo) {
//                // 解析封装 PageVo 对象
//                String pageUrl = html.baseUri();
//                System.out.println(pageUrl + "：" + pageVo.toString());
//                // 处理业务代码
//            }
//        };
//    }



    @Setter
    @Getter
    @PageSelect(cssQuery = "#search-projects-ulist .project")
    public static class DemoPageVo {

        @PageFieldSelect(cssQuery = ".repository")
        private String repository;

        @PageFieldSelect(cssQuery = ".description")
        private String description;

        @Override
        public String toString() {
            return "PageVo{" +
                    "repository='" + repository + '\'' +
                    ", description='" + description + '\'' +
                    '}';
        }
    }

}
